package com.yunjinsuke.recharge.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;


/**
 * 充值订单
 */
@Entity
@DynamicUpdate
@Table(name = "recharge_order", indexes = {
        @Index(columnList = "mchId")
})
@org.hibernate.annotations.Table(appliesTo = "recharge_order", comment = "充值订单")
@Data
@EqualsAndHashCode(callSuper = true)

public class RechargeOrder extends BaseEntity {
    /**
     * 等待
     */
    public static final String WAITING = "waiting";
    /**
     * 成功
     */
    public static final String SUCCEED = "succeed";
    /**
     * 失败
     */
    public static final String FAILED = "failed";

    /**
     * 商户号
     */
    @Column(nullable = false, columnDefinition = "varchar(24) comment '商户号'")
    private String mchId;

    /**
     * 处理端口(无用数据，只为测压观察)
     */
    @Column(columnDefinition = "varchar(11) comment '处理端口'")
    private String serverPort;

    /**
     * 手机号
     */
    @Column(nullable = false, columnDefinition = "varchar(11) comment '手机号'")
    private String mobile;

    /**
     * 金额
     */
    @Column(nullable = false, columnDefinition = "int(11) comment '金额'")
    private Integer amount;

    /**
     * 充值状态 waiting:充值中 succeed:成功 failed:失败
     */
    @Column(nullable = false, columnDefinition = "varchar(10) comment '充值状态 waiting:充值中 succeed:成功 failed:失败'")
    private String rechargeState = WAITING;

}
